/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pb138.simpleLibrary;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author vramik
 */
public class ReaderManagerImpl implements ReaderManger {

    Set<Reader> readers = new HashSet<Reader>();
    
    @Override
    public void addReader(Reader reader) {
        readers.add(reader);
    }

    @Override
    public void removeReader(Reader reader) {
        readers.remove(reader);
    }

    @Override
    public Set<Reader> findAllReaders() {
        return Collections.unmodifiableSet(readers);
    }

    @Override
    public Reader findReaderById(Long id) {
        Reader wantedReader = null;
        for (Reader reader : readers) {
            if (reader.getId().equals(id)) {
                wantedReader = reader;
            }
        }
        return wantedReader;
    }

    @Override
    public void updateReader(Reader reader) {
        readers.remove(reader);
        readers.add(reader);
    }
    
}
